#include <iostream>

using namespace std;

int board[9][9];
bool col[9][10];
bool row[9][10];
bool grid[10][10][10];

bool dfs(int i, int j)
{
    if(j == 9)
    {
        i++;
        j = 0;
    }

    if(i == 9) return true;
    if(board[i][j]) return dfs(i, j + 1);

    for(int x = 1; x <= 9; x++)
    {
        if(row[i][x] || col[j][x] || grid[i / 3][j / 3][x]) continue;

        row[i][x] = col[j][x] = grid[i / 3][j / 3][x] = true;
        board[i][j] = x;
        if(dfs(i, j + 1)) return true;
        row[i][x] = col[j][x] = grid[i / 3][j / 3][x] = false;
        board[i][j] = 0;
    }
    return false;
}
int main()
{
    for(int i = 0; i < 9; i++)
    {
        for(int j = 0; j < 9; j++)
        {
            cin >> board[i][j]; 
            if(board[i][j])
            {
                int num = board[i][j];
                row[i][num] = col[j][num] = grid[i / 3][j / 3][num] = true;
            }
        }
    }
    dfs(0, 0);

    for(int i = 0; i < 9; i++)
    {
        for(int j = 0; j < 9; j++)
        {
            cout << board[i][j] << " "; 
        }
        cout << endl;
    }

    return 0;
}
